Skip to content

Expose a native polling method for both authorization and order contexts - #10

Open
microalps wants to merge 6 commits into
webprofusion:mainfrom
microalps:feature/polling-step
Open

Expose a native polling method for both authorization and order contexts#10
microalps wants to merge 6 commits into
webprofusion:mainfrom
microalps:feature/polling-step

Conversation

@microalps

@microalps microalps commented Jul 17, 2026

Copy link
Copy Markdown

This PR adds a polling step to the ACME client flow to better handle asynchronous processing/status transitions.

What changed

  • Introduced a polling step in the relevant ACME workflow.
  • Updated logic to handle repeated status checks and progression.
  • Corrected unit tests that were already failing prior to this work.
  • Ensured tests align with updated polling behavior.

Why

  • Some ACME operations are asynchronous and require repeated status checks. Adding explicit polling improves robustness and correctness of client behavior.
  • Additionally, pre-existing failing unit tests were fixed to restore confidence in the test suite.

Notes

  • This was not yet tested against an ACME provider
  • This does not correct the documentation flaws in APIv2.md. It seems that the poll for status step is not documented at all and expects ACME to be instantaneous.
  • There was some work introduced in main after the latest release to wait for download automatically. This superseded that effort with an exposed retry mechanism.

Excerpt from RFC 8555

Action Request Response
Respond to challenges POST authorization challenge urls 200
Poll for status POST-as-GET order 200
Finalize order POST order's finalize url 200
Poll for status POST-as-GET order 200
Download certificate POST-as-GET order's certificate url 200

@webprofusion-chrisc

Copy link
Copy Markdown
Contributor

Thanks, this is a good idea so worth pursing a little more. The way we currently use this library is from a higher level consumer which has retries but building it into the library consistently would be good.

Things it needs:

  • A configurable preferred retry delay and max retry count, instead of waiting 3 seconds and passing in a specific number of retries. This is becomes some CAs are much slower than others, sometimes taking several minutes to complete. Ideally this would be fed into the order context and used where appropriate in the request pipeline.
  • Where possible if the ACME server responds with a retry-after header (already used in some places) we should try to honour that, unless the retry-after is not specified or exceeds our max wait time (retry count * retry delay, or something we configure on the order context)

@microalps

Copy link
Copy Markdown
Author

I thought about your second point. However, to implement this we must change the retryCount to a retryTimeout (say, two minutes) so that ACME server doesn't hang the process by giving a retry in an unexpected range (e.g. 1 day). Using retryCount * retryDelay doesn't account for latency of the request itself. Is that acceptable to you as this would be a behavior change to the Generate/Download methods?

@webprofusion-chrisc

Copy link
Copy Markdown
Contributor

Yes, an overall retry/operation timeout would be easier for users to understand as well. Internally we probably care about how often we retry, but users don't.

@microalps

microalps commented Jul 19, 2026

Copy link
Copy Markdown
Author

Due to it being a public API (which, FYI, was changed in post 3.3.3 to have a different default of 3 retries) this is now a breaking change. I tried to make a backward-compatible implementation, but it isn't exactly going to follow the 3 retry logic. Some examples (theoretically):

  1. If the server doesn't give Retry-After, it might take 2.5 seconds for first 2 requests (latency+wait) and then wait just 1 second for the 3rd request so it respects the 6 second timeout
  2. If the server replies to retry in 1 second, and it isn't ready then and again says retry in 1 second, the 6 seconds will result in ~6 retries.
  3. If the server replies to retry in 5 seconds, it will only do 2 retries before timing out. If the server replies to retry in 10 seconds, it will retry once after ~6 seconds ignoring the server's request.

I guess if this is merged it should be bumped as v3.4.0

@microalps

Copy link
Copy Markdown
Author

@webprofusion-chrisc what is needed to merge? Are you testing against an actual CA?

@webprofusion-chrisc

Copy link
Copy Markdown
Contributor

Thanks, it's really just waiting for me to find time to properly review it but just looking over the diff there are still several places where a literal value of seconds (3, 15 etc) is specified and we need to make these configurable.

@microalps

Copy link
Copy Markdown
Author

Thanks, it's really just waiting for me to find time to properly review it but just looking over the diff there are still several places where a literal value of seconds (3, 15 etc) is specified and we need to make these configurable.

I believe the hard-coded values were there before. The new explicit methods for waiting are fully configurable, it's specifically if you Download skipping the new wait method or use the deprecated Generate utility method (does anyone use that in practice, or mostly used by testing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants